<?php /* 程序侠版权所有 技术论坛支持: bbs.chengxuxia.com QQ: 573907419 正版授权防止出现漏洞后门
-- enphp : https://git.oschina.net/mz/mzphp2
 */
error_reporting(E_ALL ^ E_NOTICE);

use think\Session;
use think\Response;
use think\Request;
use think\Url;

if (!function_exists(curl_file_create)) {
    function curl_file_create($var_1, $var_2 = '', $var_3 = '')
    {
        return "@$var_1;filename=" . ($var_3 ?: basename($var_1)) . ($var_2 ? ";type=$var_2" : '');
    }
}
if (!function_exists(array_sort)) {
    function array_sort($var_5, $var_6, $var_7)
    {
        $var_9 = array();
        foreach ($var_5 as $var_10) {
            $var_9[$var_10[$var_6]] = $var_10;
        }
        if ($var_7 == 'asc') {
            ksort($var_9);
        } elseif ($var_7 = 'desc') {
            krsort($var_9);
        } else {
        }
        return $var_9;
    }
}
if (!function_exists('search_array')) {
    /** info：返回$searchData数组中存在键值$searchKey=>$searchResult的数组
     * @param $searchData
     * @param $searchKey
     * @param $searchResult
     * @return array
     */
    function search_array($searchData, $searchKey, $searchResult)
    {
        $returnData = array();
        foreach ($searchData as $key => $value) {
            if ($value[$searchKey] == $searchResult) {
                $returnData = $value;
            }
        }
        return $returnData;
    }
}
function flash($var_17, $var_18 = false)
{
    $var_20 = 'flash_';
    if ('?' == substr($var_17, 0, 1)) {
        return Session::has($var_20 . substr($var_17, 1));
    } else {
        $var_21 = $var_20 . $var_17;
        if (!1 === $var_18) {
            $var_22 = Session::pull($var_21);
            return null === $var_22 ? null : unserialize($var_22);
        } else {
            return Session::set($var_21, serialize($var_18));
        }
    }
}

function sort_by($var_23, $var_24 = '')
{
    $var_26 = Request::instance()->param('_sort');
    $var_27 = Request::instance()->get();
    $var_27['_sort'] = ($var_26 == 'asc' ? 'desc' : 'asc');
    $var_27['_order'] = $var_24;
    $var_28 = Url::build(Request::instance()->{action}(), $var_27);
    return Request::instance()->param('_order') == $var_24 ? "<a href='{$var_28}' title='点击排序' class='sorting-box sorting-{$var_26}'>{$var_23}</a>" : "<a href='{$var_28}' title='点击排序' class='sorting-box sorting'>{$var_23}</a>";
}

function high_light($var_29, $var_30 = '', $var_31 = 'c-red')
{
    return $var_30 !== '' ? str_replace($var_30, "<span class='{$var_31}'>" . $var_30 . '</span>', $var_29) : $var_29;
}

if (!function_exists(show_status)) {
    function show_status($var_33, $var_34, $var_35 = 'status', $var_36 = '')
    {
        $var_36 === '' && $var_36 = Request::instance()->{controller}();
        switch ($var_33) {
            case 0:
                $var_38 = '<span data-toggle=\"tooltip\" data-placement=\"top\" data-title=\"点击启用\" onclick=\"ajax_req(\'' . Url::build($var_36 . '/resume', ['id' => $var_34, 'field' => $var_35]) . '\',{},change_status,[this,\'resume\'])\" class=\"f-18 c-error\" style=\"cursor:pointer\" ><i class=\"Hui-iconfont\">&#xe6e0;</i></span>';
                break;
            case 1:
                $var_38 = '<span data-toggle=\"tooltip\" data-placement=\"top\" data-title=\"点击禁用\" onclick=\"ajax_req(\'' . Url::build($var_36 . '/forbid', ['id' => $var_34, 'field' => $var_35]) . '\',{},change_status,[this,\'forbid\'])\" class=\"f-18 c-success\" style=\"cursor:pointer\" ><i class=\"Hui-iconfont\">&#xe6e1;</i></span>';
                break;
        }
        return $var_38;
    }
}
if (!function_exists(get_md5_file)) {
    function get_md5_file($var_39)
    {
        $var_41 = @fopen($var_39, 'r');
        $var_42 = array();
        $var_43 = array();
        $var_44 = 0;
        if ($var_41) {
            while (!feof($var_41)) {
                $var_45 = fgets($var_41);
                $var_46 = explode('*', $var_45);
                $var_42[$var_44] = array_filter($var_46);
                $var_44++;
            }
            $var_42 = array_filter($var_42);
            fclose($var_41);
        }
        foreach ($var_42 as $var_44 => $var_47) {
            $var_43[$var_44][md5] = trim($var_47[0]);
            $var_43[$var_44]['path'] = trim($var_47[1]);
        }
        return $var_43;
    }
}
if (!function_exists(get_md5_file)) {
    function read_file($var_48)
    {
        $var_50 = '';
        if (function_exists(file_get_contents)) {
            @$var_50 = file_get_contents($var_48);
        } else {
            if (@$var_51 = fopen($var_48, 'r')) {
                @$var_50 = fread($var_51, filesize($var_48));
                @fclose($var_51);
            }
        }
        return $var_50;
    }
}
if (!function_exists(write_file)) {
    function write_file($var_52, $var_53, $var_54 = 'a')
    {
        if (@$var_56 = fopen($var_52, $var_54)) {
            flock($var_56, 2);
            fwrite($var_56, $var_53);
            fclose($var_56);
            clearstatcache();
            return !0;
        } else {
            return !1;
        }
    }
}
if (!function_exists(friend_date)) {
    function friend_date($var_57)
    {
        if (!$var_57) return !1;
        $var_59 = '';
        $var_60 = time() - intval($var_57);
        $var_61 = $var_57 - mktime(0, 0, 0, 0, 0, date('Y'));
        $var_62 = $var_57 - mktime(0, 0, 0, date('m'), 0, date('Y'));
        $var_63 = $var_57 - mktime(0, 0, 0, date('m'), date('d') - 2, date('Y'));
        $var_64 = $var_57 - mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
        $var_65 = $var_57 - mktime(0, 0, 0, date('m'), date('d'), date('Y'));
        $var_66 = $var_57 - mktime(0, 0, 0, date('m'), date('d') + 1, date('Y'));
        $var_67 = $var_57 - mktime(0, 0, 0, date('m'), date('d') + 2, date('Y'));
        if ($var_60 == 0) {
            $var_59 = '刚刚';
        } else {
            switch ($var_60) {
                case $var_60 < $var_67:
                    $var_59 = date('Y年m月d日', $var_57);
                    break;
                case $var_60 < $var_66:
                    $var_59 = '后天' . date('H:i', $var_57);
                    break;
                case $var_60 < 0:
                    $var_59 = '明天' . date('H:i', $var_57);
                    break;
                case $var_60 < 60:
                    $var_59 = $var_60 . '秒前';
                    break;
                case $var_60 < 3600:
                    $var_59 = floor($var_60 / 60) . '分钟前';
                    break;
                case $var_60 < $var_65:
                    $var_59 = floor($var_60 / 3600) . '小时前';
                    break;
                case $var_60 < $var_64:
                    $var_59 = '昨天' . date('H:i', $var_57);
                    break;
                case $var_60 < $var_63:
                    $var_59 = '前天' . date('H:i', $var_57);
                    break;
                case $var_60 < $var_62:
                    $var_59 = date('m月d日 H:i', $var_57);
                    break;
                case $var_60 < $var_61:
                    $var_59 = date('m月d日', $var_57);
                    break;
                default:
                    $var_59 = date('Y年m月d日', $var_57);
                    break;
            }
        }
        return $var_59;
    }
}
function filter_value($var_68, $var_69, $var_70 = false)
{
    $var_72 = [];
    foreach ($var_68 as $var_73 => $var_74) {
        if (isset($var_74[$var_69])) $var_72[] = $var_74[$var_69];
    }
    if (!empty($var_72)) {
        $var_72 = array_flip(array_flip($var_72));
        sort($var_72);
    }
    return $var_70 ? implode(',', $var_72) : $var_72;
}

function reset_by_key($var_75, $var_76)
{
    $var_77 = [];
    foreach ($var_75 as $var_78) {
        $var_77[$var_78[$var_76]] = $var_78;
    }
    return $var_77;
}

function get_random($var_79 = '')
{
    return $var_79 . base_convert(time() * 1000, 10, 36) . '_' . base_convert(microtime(), 10, 36) . uniqid();
}

function list_sort_by($var_81, $var_82, $var_83 = 'asc')
{
    if (is_array($var_81)) {
        $var_85 = $var_86 = [];
        foreach ($var_81 as $var_87 => $var_88) $var_85[$var_87] =& $var_88[$var_82];
        switch ($var_83) {
            case 'asc':
                asort($var_85);
                break;
            case 'desc':
                arsort($var_85);
                break;
            case 'nat':
                natcasesort($var_85);
                break;
        }
        foreach ($var_85 as $var_89 => $var_90) $var_86[] =& $var_81[$var_89];
        return $var_86;
    }
    return !1;
}

function format_bytes($var_91, $var_92 = '')
{
    $var_94 = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
    for ($var_95 = 0; $var_91 >= 1024 && $var_95 < 5; $var_95++) $var_91 /= 1024;
    return round($var_91, 2) . $var_92 . $var_94[$var_95];
}

